package com.prelearning.at_springboot.controller;

import com.prelearning.at_springboot.entity.TestData;
import com.prelearning.at_springboot.mapper.TestDataMapper;
import com.prelearning.at_springboot.service.TestDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("td")
public class TestController {

    @Autowired
    private TestDataService testDataService;

    @PostMapping
    public boolean save(@RequestBody TestData testData){ //@requestbody 可以把前台传入的json对象转成testData对象
        return testDataService.saveTestData(testData);
    }

    @GetMapping("")
    public List<TestData> findAll(){ return testDataService.list(); }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id){
        return testDataService.removeById(id);
    }

}
